<script lang="js">
import {defineComponent} from 'vue'
import {fetchEventSource} from "@fortaine/fetch-event-source";

export default defineComponent({
  name: "SseDemo2",
  data() {
    return {
      typedMessage: ''
    }
  },
  methods: {
    startListening() {
      fetchEventSource("http://localhost:8080", {
        onmessage: (event) => {
          console.log('update', event.data)
          this.typedMessage += event.data
        },
      })
    }
  },
  mounted() {
    this.startListening();
  }
})
</script>

<template>
  <div>
    <div>SseDemo2</div>
    <div>{{ typedMessage }}</div>
  </div>
</template>

<style scoped>

</style>
